package com.itheima.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.itheima.service.BookService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

public class JdbcConfig {
    @Value("com.mysql.jdbc.Driver")
    private String drive;
    @Value("jdbc:mysql://localhost:3306/demo")
    private String url;
    @Value("root")
    private String username;
    @Value("Lc610256")
    private String password;

    @Bean
    public DataSource dataSource(BookService bookService) {
        System.out.println(bookService);
        DruidDataSource ds = new DruidDataSource();

        ds.setDriverClassName(drive);
        ds.setUrl(url);
        ds.setUsername(username);
        ds.setPassword(password);

        return ds;
    }
}
